using System;

namespace OneGame.Gameplay
{
    public class AttributeWatcher
    {
        public int CurrentValue
        {
            get => _currentValue;
            set => SetValue(value);
        }

        public event Action<int, int> OnValueChanged;

        private int _currentValue;

        public void Init(int currentValue, int maxValue)
        {
            _currentValue = currentValue;
        }

        private void SetValue(int value)
        {
            var diff = value - _currentValue;
            if (diff != 0)
            {
                _currentValue = value;
                OnValueChanged?.Invoke(_currentValue, diff);
            }
        }
    }
}